﻿using System;
using System.Collections.Generic;
using OestsCommon.Model;
using OestsCommon.TcpNet;
using OestsServer.Managers;
using OestsServer.Net;

namespace OestsServer.Handlers
{
	public class LeaveRoomHandler : HandlerBase
	{
		public override PacketKey PKey => PacketKey.LeaveRoom;

		public override void Execute(ClientChannel client, Request ResquestPacket)
		{
			//int houseOwnerId = int.Parse(ResquestPacket.DataStr);
			//int studentId = client.User.DBid;

			//foreach (var room in RoomManager.Instance.RoomList)
			//{
			//	if (room.RoomId == houseOwnerId)
			//	{
			//		LeaveRoom(room, studentId);
			//		//由于自己被移除了  不在房间里面，所以另外发送
			//		client.Send(ResponsePacket);
			//		break;
			//	}
			//}
		}
		public void LeaveRoom(Room room, int studentId)
		{
			////移除成员信息
			//if (room.StudentTemps.Contains(studentId))
			//{
			//	room.StudentTemps.Remove(studentId);
			//}
			////如果离开的成员已选择了岗位，清除选择的岗位
			//if (room.DicPostIdStudentId.ContainsValue(studentId))
			//{
			//	foreach (var item in room.DicPostIdStudentId)
			//	{
			//		if (item.Value == studentId)
			//		{
			//			room.DicPostIdStudentId[item.Key] = 0;
			//			break;
			//		}
			//	}
			//}
			//Struct2<Room, int> data = new Struct2<Room, int>();
			//data.Value1 = room;
			//data.Value2 = studentId;
			//ResponsePacket.DataObject = data;
			////广播
			//BroadcastInRoom(room, ResponsePacket);
		}
	}
}
